<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="${pageContext.request.contextPath }/js/kindeditor-4.1.10/themes/default/default.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/ajaxfileupload.js"></script>
<link id="easyuiTheme" rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/default.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"	type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/outOfBounds.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/common.js" type="text/javascript"></script>
</head>

<body>
	<table class="easyui-datagrid" id="jobList" title="职位列表" 
       data-options="rownumbers:true,singleSelect:false,collapsible:true,pagination:true,url:'${pageContext.request.contextPath}/job/list',method:'get',pageSize:30,toolbar:toolbar">
    <thead>
        <tr>
        	<th data-options="field:'ck',checkbox:true"></th>
        	<th data-options="field:'id',width:20,align:'center'">ID</th>
            <th data-options="field:'jobName',width:300,align:'center'">职位名称</th>
            <th data-options="field:'jobCategory',width:100,align:'center',formatter:HONGXIN.formatJobCategory">职位类别</th>
            <th data-options="field:'sex',width:80,align:'center'">性别要求</th>
            <th data-options="field:'education',width:80,align:'center'">学历要求</th>
            <th data-options="field:'remark',width:80,align:'center'">薪资</th>
            <th data-options="field:'jobNum',width:80,align:'center'">招聘人数</th>
            <th data-options="field:'jobPushtime',width:130,align:'center',formatter:HONGXIN.formatDateTime">发布时间</th>
            <th data-options="field:'ispush',width:60,align:'center',formatter:HONGXIN.formatStatus">是否发布</th>
            <th data-options="field:'status',width:60,align:'center',formatter:HONGXIN.formatStatus">有效状态</th>
        </tr>
    </thead>
</table>

</body>
<div id="jobEditWindow" class="easyui-window" title="编辑职位" data-options="modal:true,closed:true,iconCls:'icon-save',href:'${pageContext.request.contextPath }/job/job_edit'" style="width:1000px;height:500px;padding:10px;"></div>
<div id="jobViewWindow" class="easyui-window" title="查看职位" data-options="modal:true,closed:true,iconCls:'icon-save',href:'${pageContext.request.contextPath }/job/job_view'" style="width:1000px;height:500px;padding:10px;"></div>
<script>

    function getSelectionsIds(){
    	var jobList = $("#jobList");
    	var sels = jobList.datagrid("getSelections");
    	var ids = [];
    	for(var i in sels){
    		ids.push(sels[i].id);
    	}
    	ids = ids.join(",");
    	return ids;
    }
    
    var toolbar = [{
        text:'编辑',
        iconCls:'icon-edit',
        handler:function(){
        	var ids = getSelectionsIds();
        	if(ids.length == 0){
        		$.messager.alert('提示','必须选择一则文章才能编辑!');
        		return ;
        	}
        	if(ids.indexOf(',') > 0){
        		$.messager.alert('提示','只能选择一则文章!');
        		return ;
        	}
        	
        	$("#jobEditWindow").window({
            		onLoad :function(){
            			//回显基础数据
            			//获取选中行的数据
            			var data = $("#jobList").datagrid("getSelections")[0];
            			
            			$("#jobEditForm").form("load",data);
            			
            			var jobEditEditor ;
            			$(function(){
            				//实例化编辑器
            				jobEditEditor = HONGXIN.createEditor("#jobEditForm [name=content]");
            			});       		
            		}            		
            	}
            	).window("open");

        	
        }
    },{
        text:'删除',
        iconCls:'icon-cancel',
        handler:function(){
        	var ids = getSelectionsIds();
        	if(ids.length == 0){
        		$.messager.alert('提示','未选中文章!');
        		return ;
        	}
        	$.messager.confirm('确认','确定删除ID为 '+ids+' 的文章吗？',function(r){
        	    if (r){
        	    	var params = {"ids":ids};
                	$.post("delete",params, function(data){
            			if(data.status == 200){
            				$.messager.alert('提示','删除文章成功!',undefined,function(){
            					$("#jobList").datagrid("reload");
            				});
            			}
            		});
        	    }
        	});
        }
    },{
        text:'还原',
        iconCls:'icon-remove',
        handler:function(){
        	var ids = getSelectionsIds();
        	if(ids.length == 0){
        		$.messager.alert('提示','未选中文章!');
        		return ;
        	}
        	$.messager.confirm('确认','确定还原ID为 '+ids+' 的文章吗？',function(r){
        	    if (r){
        	    	var params = {"ids":ids};
                	$.post("restore",params, function(data){
            			if(data.status == 200){
            				$.messager.alert('提示','还原文章成功!',undefined,function(){
            					$("#jobList").datagrid("reload");
            				});
            			}
            		});
        	    }
        	});
        }
    }];
    
  $('#jobList').datagrid({  
	  onDblClickRow: function (rowIndex, rowData) { 
		  $("#jobViewWindow").window({
      		onLoad :function(){
      			//回显基础数据
      			//获取选中行的数据
      			//var data = $("#jobList").datagrid("getSelections")[0];
      			
      			$("#jobViewForm").form("load",rowData);
      			$('#showContent').append($('#content').val());
      		}            		
      	}
      	).window("open");
		  
	  }
  });  
    
    


</script>